package com.atde._05_behavioral_design_patterns.memento;


/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde._05_behavioral_design_patterns.memento
 * @Author: Del
 * @CreateTime: 2025-06-30  02:19
 * @Description: 备忘录模式 -- 原始对象
 * @Version: 1.0
 */
public class Originator {
    // 状态信息
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    // 编写一个方法，可以保存一个状态对象 Memento
    public Memento saveStateMemento() {
        return new Memento(state);
    }

    // 恢复一个状态对象 Memento
    public void getStateFromMemento(Memento memento) {
        state = memento.getState();
    }
}
